import request, { SERVER_API_HOST, deleteReq } from '../utils/request';
import encodeParam from '../utils/params';

// add meeting room detail
/**
 *
 * @param {space_id, room_name, cover, big, address, people, price, label, item} params
 */
export async function addMeetingRoom(params) {
  return request(`${SERVER_API_HOST}/meetingrooms`, {
    method: 'POST',
    body: params,
  });
}
// update meeting room detail
/**
 *
 * @param {room_name, cover, big, address, people, price, label, item } params
 *
 */
export async function updateMeetingRoom(params) {
  const encodedParam = encodeParam(params);
  return request(`${SERVER_API_HOST}/meetingrooms/${params.id}?${encodedParam}`, {
    method: 'PUT',
  });
}
// query meeting room detail
/**
 *
 * @param {id} params
 */
export async function queryMeetingRoom(id) {
  return request(`${SERVER_API_HOST}/meetingrooms/${id}`, {
    method: 'GET',
  });
}
// delete meeting room detail
/**
 * @param {id} params
 */
export async function deleteMeetingRoom(id) {
  return deleteReq(`${SERVER_API_HOST}/meetingrooms/${id}`, {
    method: 'DELETE',
  });
}
// query meeting list
/**
 *
 * @param {space_id, page, amount} params
 */
export async function queryMeetingRoomList(params) {
  const encodedParam = encodeParam(params);
  return request(`${SERVER_API_HOST}/meetingrooms?${encodedParam}`, {
    method: 'GET',
  });
}
